<?php
/**
 * @author wesley
 * @version v1.0
 * @time 2021/6/29 17:42
 * @desc
 */

namespace app\api\validate;


//use think\Exception;
//use think\Request;
use app\lib\exception\ParameterException;
use think\facade\Request;
use think\Validate;

class BaseValidate extends Validate
{
    /**
     * @throws \think\Exception
     */
    public function goCheck()
    {
        // 获取参数
        // 参数校验
//        $request = Request::instance();
        $params=Request::param();

        $result = $this->batch()->check($params);
        if(!$result){
            throw new ParameterException([
                'msg'=> $this->error
            ]);
//            $error = $this->error;
//            throw new \think\Exception($error);
        }else {
            return true;
        }
    }
}